package com.yunhe.energy.client.fallback;

import com.yunhe.energy.client.AuthorityClient;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.Firm;
import com.yunhe.common.model.authority.Station;
import com.yunhe.common.model.authority.User;
import com.yunhe.common.model.base.Area;
import com.yunhe.common.model.company.Company;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author liuronglei
 */
@Component
public class AuthorityFallbackFactory implements FallbackFactory<AuthorityClient> {
    @Override
    public AuthorityClient create(Throwable arg0) {
        return new AuthorityClient() {

            @Override
            public ResponseEntity<ResultObject<Firm>> getFirmByCode(Long code) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Firm>> getFirm(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Firm>> getFirmByStation(Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Station>> getStationByCode(Long code) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Station>> getStation(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<User>> getUserByName(String name) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Station>> getStationByDevCode(Long devCode) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Station>>> getStationByFirmId(Long firmId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Area>> getAreaByStationCode(Long stationCode) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Area>> getAreaByFirmCode(Long firmCode) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Company>>> getCompanys(Long firmId, Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
